<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>Date时间对象</title>
	<script type="text/javascript">
	//创建现在的日期时间对象实例
    //today就是刚创建的Date对象实例
    var today  = new Date();
    document.write(today+"<br/>");

    //计算你今年多大了
    //1.创建现在的日期对象，取出当前的毫秒值
    var now = new Date();
    var nowtime = now.getTime();
    //2.创建出生日期时的日期对象，取出那时的毫秒值
    var age = new Date("1985/12/5");
    var agetime = age.getTime();
     //3.两个毫秒相减
     var str = (nowtime-agetime)/1000/3600/24/365;
     document.write("你今年"+str+"岁了<br/>");
      //计算你今年多大了
      //1.创建现在的日期对象，取出当前的毫秒值
      var now = new Date();
      var nowtime = now.getTime();
      //2.创建未来日期时的日期对象，取出那时的毫秒值
      var future = new Date(1985+100,12,5);
      var futuretime = future.getTime();
       //3.两个毫秒相减
       var str = (futuretime-nowtime)/1000/3600/24;
       document.write("你还要活"+str+"天，才能到100岁");

     
	</script>
</head>
<body>

</body>
</html>